var t = require("../../res/www.a9a.cn.js"),
  i = getApp(),
  a = wx.getStorageSync("COOK_U");
Page({
  data: { nTitle: "", triggered: !0 },
  onLoad: function (a) {
    wx.showNavigationBarLoading();
    var e = this,
      n = 0,
      o = 0;
    i.get_config("_ZEAI").then(function (a) {
      e.setData({ color: i._ZEAI.color, rgbcolor: t.c16_rgb(i._ZEAI.color) });
    });
    var r = a.t;
    if (((r = i.empty(r) ? "" : r), t.ifint(a.tguid) || t.ifint(a.admid)))
      (n = t.ifint(a.tguid) ? a.tguid : 0),
        (o = t.ifint(a.admid) ? a.admid : 0);
    else {
      for (
        var s = decodeURIComponent(a.scene), g = {}, l = 0;
        l < s.split("*").length;
        l++
      ) {
        var c = s.split("*")[l].split("/");
        g[c[0]] = c[1];
      }
      (o = t.ifint(g.a) ? g.a : 0), (n = t.ifint(g.t) ? g.t : 0), (r = "");
    }
    i.get_navigationBarTopHeight(e),
      i.get_openid().then(function (t) {
        e.init();
      }),
      e.setData({ t: r, tguid: n, admid: o }),
      console.log("reg->  tguid=" + n),
      console.log("reg->  admid=" + o);
  },
  init: function () {
    var e = this;
    (a = wx.getStorageSync("COOK_U")),
      wx.showNavigationBarLoading(),
      wx.showLoading({ title: "玩命加载中", mask: !0 }),
      i.ajax({
        url: "tg.php",
        data: { submitok: "reg", openid: a.openid },
        success: function (a) {
          if (
            (wx.setNavigationBarTitle({ title: a.nTitle }),
            wx.hideNavigationBarLoading(),
            wx.hideLoading(),
            1 == a.flag)
          )
            "flag1" == a.t
              ? wx.redirectTo({ url: "my" })
              : e.setData({
                  nTitle: a.nTitle,
                  TGU: a.TGU,
                  t: a.t,
                  MB: a.MB,
                  HELP: a.D,
                });
          else {
            if (0 == a.flag)
              return (
                (a.this = e),
                (a.url = "no"),
                t.sorry(a),
                void e.setData({ flag: a.flag })
              );
            i.empty(a.t)
              ? e.setData({
                  nTitle: a.nTitle,
                  h1: a.h1,
                  h5: a.h5,
                  btn_u: a.btn_u,
                  btn_tg: a.btn_tg,
                })
              : ((a.this = e), (a.url = "no"), t.sorry(a));
          }
        },
      });
  },
  onPullDownRefresh: function () {
    var t = this;
    wx.vibrateShort({ type: "heavy" }),
      setTimeout(function () {
        t.setData({ triggered: !1 }), t.init();
      }, 500);
  },
  payFn: function () {
    var e = this;
    t.empty(e.data.MB) || i.openSetting(e.data.MB),
      (a = wx.getStorageSync("COOK_U")),
      wx.showLoading({ title: "玩命加载中", mask: !0 }),
      i.ajax({
        url: "tg.php",
        data: { submitok: "reg_pay_active", openid: a.openid },
        success: function (n) {
          wx.hideLoading(),
            1 == n.flag
              ? wx.showModal({
                  content: n.msg,
                  confirmColor: e.data.color,
                  confirmText: "朕知道了",
                  showCancel: !1,
                  success: function (t) {
                    wx.reLaunch({ url: "my" });
                  },
                })
              : "pay" == n.flag
              ? i.pay({
                  data: { submitok: "tg_pay_active", openid: a.openid },
                  success: function (i) {
                    1 == i.flag
                      ? wx.showModal({
                          content: "激活成功！",
                          confirmColor: e.data.color,
                          confirmText: "朕知道了",
                          showCancel: !1,
                          success: function (t) {
                            wx.reLaunch({ url: "my" });
                          },
                        })
                      : ((n.this = e), (n.url = "no"), t.sorry(n));
                  },
                  fail: function (i) {
                    (i.this = e), (i.url = "no"), t.sorry(i);
                  },
                })
              : ((n.this = e), (n.url = "no"), t.sorry(n));
        },
      });
  },
  onShareAppMessage: function () {
    return {
      imageUrl: this.data.loading.share.imgurl,
      title: this.data.loading.share.title,
      path: "/pages/tg/reg",
    };
  },
  onShareTimeline: function () {
    return {
      imageUrl: this.data.loading.share.imgurl,
      title: this.data.loading.share.title,
      query: "",
      path: "/pages/tg/reg",
    };
  },
  privacy_agree: function (t) {},
  privacy_disagree: function (t) {
    console.log("disagree"), wx.exitMiniProgram();
  },
});
